package com.dyna.digit.process.dao;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dyna.digit.process.domain.entity.DigitDeclare;
import com.dyna.digit.process.mapper.DigitDeclareMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * @author zhoucaiwang
 * @date 2023/12/24
 */

@Service
public class DigitDeclareDao extends ServiceImpl<DigitDeclareMapper, DigitDeclare> {

    /**
     * 删除申报项目信息
     * @param projectId 项目id
     * @return int
     */
    public Boolean del(Integer projectId) {
        LambdaUpdateWrapper<DigitDeclare> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.eq(ObjectUtil.isNotNull(projectId),DigitDeclare::getProjectId, projectId);
        return update(lambdaUpdateWrapper);
    }

    /**
     * 批量删除项目
     * @param projectIds 项目ids
     * @return Boolean
     */
    public Boolean batchDel(ArrayList<Integer> projectIds) {
        LambdaUpdateWrapper<DigitDeclare> digitDeclareLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        digitDeclareLambdaUpdateWrapper.in(DigitDeclare::getProjectId, projectIds);
        return update(digitDeclareLambdaUpdateWrapper);
    }

}
